<?php echo $this->fetch('member.header.html'); ?>
<style>
    .borline td {padding:10px 0px;}
    .ware_list th {text-align:left;}
.image_mask{top:0;left:0;z-index:999}
#logo_mask{width:120px;height:120px}
</style>
<script type="text/javascript">
    $(function() {
    	$.validator.addMethod("isIdCardNo", function (value, element) {
			return this.optional(element) || isIdCardNo(value);  
		}, "请正确输入您的身份证号码");
    	
        $('#profile_form').validate({
            errorPlacement: function(error, element) {
                $(element).parent('span').parent('b').after(error);
            },
            rules: {
                portrait: {
                    accept: 'gif|jpe?g|png'
                },
                user_no: {
                	isIdCardNo : $("input[name='user_no']").val(),
                    required:true
                },
                real_name: {
                    required:true
                },
                phone_mob: {
                    required:true
                }
            },
            messages: {
                portrait: {
                    accept: '支持gif、jpeg、jpg、png格式'
                },
                user_no: {
                    required: '身份证不能为空'
                },
                real_name: {
                    required: '姓名不能为空'
                },
                phone_mob: {
                    required: '手机号不能为空'
                }
                
            }
        });
        $('input[ectype="change_avatar"]').change(function() {
			if($(this).val()){
				$("#logo_mask").attr('style','background:url(<?php echo $this->res_base . "/" . 'images/logo_mask.png'; ?>)');
			}else{
				$("#logo_mask").removeAttr('style');
			}
            $('input[ectype="change_avatar"]').removeAttr('name');
            $(this).attr('name', 'portrait');
        });
    });
    
    //增加身份证验证
function isIdCardNo(num){
    　   //if (isNaN(num)) {alert("输入的不是数字！"); return false;}
    　　 var len = num.length, re;
    　　 if (len == 15) 
    　　 re = new RegExp(/^(\d{6})()?(\d{2})(\d{2})(\d{2})(\d{2})(\w)$/); 
    　　 else if (len == 18) 
    　　 re = new RegExp(/^(\d{6})()?(\d{4})(\d{2})(\d{2})(\d{3})(\w)$/); 
    　　 else {
            //alert("输入的数字位数不对。"); 
            return false;
        } 
    　　 var a = num.match(re); 
    　　 if (a != null) 
    　　 { 
    　　 if (len==15) 
    　　 { 
    　　 var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]); 
    　　 var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5]; 
    　　 } 
    　　 else 
    　　 { 
    　　 var D = new Date(a[3]+"/"+a[4]+"/"+a[5]); 
    　　 var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5]; 
    　　 } 
    　　 if (!B) {
            //alert("输入的身份证号 "+ a[0] +" 里出生日期不对。"); 
            return false;
        } 
    　　 } 
    　　 if(!re.test(num)){
            //alert("身份证最后一位只能是数字和字母。");
            return false;
        }
    　　 return true; 
    }
</script>
<div class="content">
    <?php echo $this->fetch('member.menu.html'); ?>
    <div id="right">
        <?php echo $this->fetch('member.curlocal.html'); ?>
        <?php echo $this->fetch('member.submenu.html'); ?>
        <div class="wrap">
            <div class="public">
                <form method="post" enctype="multipart/form-data" id="profile_form">
                    <div class="information">
                        <?php if (! $this->_var['edit_avatar']): ?>
                        <div class="photo width13">
                            <div class="relative"><div class="absolute image_mask" id="logo_mask"></div><img src="<?php if ($this->_var['profile']['portrait']): ?><?php echo $this->_var['profile']['portrait']; ?>?<?php echo $this->_var['random_number']; ?><?php else: ?><?php echo $this->_var['site_url']; ?>/data/system/default_user_portrait.gif<?php endif; ?>" width="120" height="120" alt="" ectype="avatar" /></div>
                            <b>
                                <span class="file1"><input type="file" size="1" maxlength="0" hidefocus="true" ectype="change_avatar" name="portrait1" /></span>
                                <span class="file2"><input type="file" size="1" maxlength="0" hidefocus="true" ectype="change_avatar" name="portrait2" /></span>
                                <div class="txt">更换头像</div>
                            </b>
                        </div>
                        <?php endif; ?>
                        <div class="info individual">
                            <table>
                                <tr>
                                    <th class="width4">用户名: </th>
                                    <td><?php echo htmlspecialchars($this->_var['profile']['user_name']); ?></td>
                                </tr>
                                <tr>
                                    <th>电子邮箱:</th>
                                    <td><?php echo $this->_var['profile']['email']; ?></td>
                                </tr>
                                <tr>
                                    <th>真实姓名:</th>
                                    <td><b><span><input type="text" class="text width_normal" name="real_name" value="<?php echo htmlspecialchars($this->_var['profile']['real_name']); ?>" /></span></b></td>
                                </tr>
                                
                                <tr>
                                    <th>身份证号:</th>
                                    <td><b><span><input type="text" class="text width_normal" name="user_no" value="<?php echo htmlspecialchars($this->_var['profile']['user_no']); ?>" /></span></b></td>
                                </tr>
                                <tr>
                                    <th>手机:</th>
                                    <td><?php echo $this->_var['profile']['phone_mob']; ?></td>
                                </tr>
                                
                                <tr>
                                    <th>性别: </th>
                                    <td class="label">
                                        <label>
                                            <input type="radio" name="gender" value="0" <?php if ($this->_var['profile']['gender'] == 0): ?>checked="checked"<?php endif; ?> />保密  </label>
                                        <label>
                                            <input type="radio" name="gender" value="1" <?php if ($this->_var['profile']['gender'] == 1): ?>checked="checked"<?php endif; ?> />男   </label>
                                        <label>
                                            <input type="radio" name="gender" value="2" <?php if ($this->_var['profile']['gender'] == 2): ?>checked="checked"<?php endif; ?> />女 </label>
                                    </td>
                                </tr>
                                <tr>
                                    <th>生日: </th>
                                    <td>
                                        <input type="text" class="text width_normal" name="birthday" id="birthday" value="<?php echo htmlspecialchars($this->_var['profile']['birthday']); ?>" />
                                    </td>
                                </tr>
                                <tr>
                                    <th>QQ:</th>
                                    <td> <input type="text" class="text width_normal" name="im_qq" value="<?php echo htmlspecialchars($this->_var['profile']['im_qq']); ?>" /></td>
                                </tr>
                                <?php if ($this->_var['edit_avatar']): ?>
                                <tr>
                                    <th>头像:</th>
                                    <td><?php echo $this->_var['edit_avatar']; ?></td>
                                </tr>
                                <?php endif; ?>
                                <tr>
                                    <th></th>
                                    <td><input type="submit" class="btn" value="保存修改" /></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
</div>
<?php echo $this->fetch('footer.html'); ?>
